package dao;

import java.util.LinkedList;
import java.util.List;
import entities.Media_Company;

public class Media_CompanyDAO 
{

	private static final Media_CompanyDAO instance = new Media_CompanyDAO();
	private List<Media_Company> media_companies;
	
	private Media_CompanyDAO(){
		media_companies = new LinkedList<Media_Company>();
		Media_Company temp = null;
		
		//temp = Media_Company.newInstance("admin", "admin@lol.com", "Jaime", "Vazquez", "admin");
		//media_companies.add(temp);
	}
	
	public static Media_CompanyDAO getInstance() {
		return instance;
	}

	public synchronized Media_Company findMedia_Company(String name) {
		Media_Company result = null;
		for (Media_Company s : media_companies){
			if (s.getName().equals(name)){
				result = s;
			}
		}
		return result;
	}

	public synchronized void addMedia_Company(Media_Company obj) throws RecordDuplicateException{
		if (findMedia_Company(obj.getName()) != null){
			throw new RecordDuplicateException("Customer with id: " + obj.getName() + " is already in the db.");
		}
		else {
			media_companies.add(obj);
		}
	}
}
